'''
订单类：
一个订单包括若干个Pieces,订单号
'''

class BatchSize:
    def __init__(self, batch, size
                 ) -> None:
        self.batch = batch
        self.size = size




class Item:
    """
    Items class for rectangles inserted into sheets
    """
    def __init__(self, width, height,
                 CornerPoint: tuple = (0, 0),
                 rotation: bool = True,oid=None,id=None,category=None,details=None) -> None:
        self.width = width
        self.height = height
        self.x = CornerPoint[0]
        self.y = CornerPoint[1]
        self.area = self.width * self.height
        self.rotated = False
        self.id = id
        self.oid = oid
        self.category = category
        self.details = details

    def __repr__(self):
        return 'Item(width=%r, height=%r, x=%r, y=%r)' % (self.width, self.height, self.x, self.y)

    def rotate(self) -> None:
        self.width, self.height = self.height, self.width
        self.rotated = False if self.rotated == True else True

class Order:
    '''以订单为单位去存储'''
    def __init__(self, oids, num, items):
        self.oids = oids
        self.num = num
        self.items = items

    def __len__(self):
        return len(self.items)
# class Batch:
#     def __init__(self):
#         self.orders = [Order()]  # type List[Order] #类型是List[order]
#
#     def insert(self,order:Order):
#         self.orders.append(order)
#
#     def __delete__(self, order:Order):
#         for ord in self.orders:
#             if ord.oids==order.oids:
#                 self.orders.remove(ord)
#                 break



